package com.caiyi.financial.nirvana.sms.service;

import com.caiyi.financial.nirvana.sms.base.service.BaseService;
import com.caiyi.financial.nirvana.sms.entity.SmsReceiveMessage;
import com.caiyi.financial.nirvana.sms.enums.ReturnCodeEnum;
import com.caiyi.financial.nirvana.sms.mapper.SmsReceiveMessageMapper;
import com.caiyi.financial.nirvana.sms.querybean.PageBean;
import com.caiyi.financial.nirvana.sms.querybean.QueryReceiveMessage;
import com.youyu.common.api.Result;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SmsReceiveMessageService extends BaseService<SmsReceiveMessage> {

    @Autowired
    private SmsReceiveMessageMapper smsReceiveMessageMapper;

    public PageBean<SmsReceiveMessage> getReceiveMessageListByParams(QueryReceiveMessage bean) {
        PageHelper.startPage(bean.getPageNum(), bean.getPageSize());
        List<SmsReceiveMessage> list = smsReceiveMessageMapper.getReceiveMessageListByParams(bean);
        PageBean<SmsReceiveMessage> pageBean = new PageBean<>(list);
        return pageBean;
    }

    /**
     * 根据多个ID查询多个数据
     *
     * @param ids id列表，逗号分隔
     * @return List
     */
    public List<SmsReceiveMessage> getReceiveMsgByIds(String ids) {
        List<Integer> idList = new ArrayList<>();
        String[] idsArray = ids.split(",");
        for (String item : idsArray) {
            idList.add(Integer.parseInt(item));
        }
        return smsReceiveMessageMapper.getReceiveMsgByIds(idList);
    }
}
